package acme.client;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class Calls {

	private static Map<API, List<String>> callMap = new HashMap<API, List<String>>();
	private static Random random = new Random();
	
	static{
		List<String> catalogCalls = new ArrayList<String>();
		catalogCalls.add("http://api.wideworldofacme.com/v1/product/1002?apikey=");
		catalogCalls.add("http://api.wideworldofacme.com/v1/brand/101?apikey=");
		catalogCalls.add("http://api.wideworldofacme.com/v1/department/3?apikey=");
		callMap.put(API.CatalogAPI, catalogCalls);

		List<String> dealCalls = new ArrayList<String>();
		dealCalls.add("http://api.wideworldofacme.com/deal?apikey=");
		callMap.put(API.DailyDealAPI, dealCalls);
	}
	
	public static List<String> getCalls(API api){
		return callMap.get(api);
	}
	
	public static String getRandomCall(API api){
		double val = random.nextDouble();
		double rawIndex = val * (getCalls(api).size() - 1);
		int index = Math.round(new Float(rawIndex));
		return getCalls(api).get(index);
	}
}
